<?php

/**
 * user form.
 *
 * @package    pendidikan indonesia
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class userForm extends BaseuserForm
{
  public function configure()
  {
      
      $this->useFields(array('id', 'nama', 'tempat_lahir', 'tanggal_lahir', 'alamat', 'id_propinsi', 'id_kota', 'email'));

      $years = range(1930, date('Y'));
      $month = array(
          1=>'Januari', 2=>'Februari', 3=>'Maret', 4=>'April',
          5=>'Mei', 6=>'Juni', 7=>'Juli', 8=>'Agustus', 9=>'September',
          10=>'Oktober', 11=>'November', 12=>'Desember'
      );

      
      
      $this->setWidget('alamat', new sfWidgetFormTextarea());
      
      $this->widgetSchema['tanggal_lahir'] = new sfWidgetFormI18nDate(array(
          'culture'=>'id',
          'format' => '%day% - %month% - %year%',
          'years' => array_combine($years, $years)
          //'months' => array_combine(array_keys($month), $month)
      ));

      $this->widgetSchema['id_propinsi'] = new sfWidgetFormChoice(array(
          'choices'=>Doctrine_core::getTable('setPropinsi')->getPropinsiList(),
          'expanded'=>false,
          'multiple'=>false,
          'label'=>'Propinsi'
      ));

      $this->widgetSchema['id_kota'] = new sfWidgetFormChoice(array(
          'choices'=>Doctrine_core::getTable('setKota')->getKotaList(),
          'expanded'=>false,
          'multiple'=>false,
          'label'=>'Kota'
      ));

      $this->validatorSchema['nama'] = new sfValidatorAnd(array(
          $this->validatorSchema['nama'], new sfValidatorString(
                    array('trim'=>true, 'min_length'=>4, 'max_length'=>100),
                    array(
                        'required'=>'Nama harus diisi',
                        'min_length'=>'Nama minimal 4 karakter',
                        'max_length'=>'Nama maksimal 100 karakter'
                    )
                  )
      ));

      $this->validatorSchema['tempat_lahir'] = new sfValidatorAnd(array(
          $this->validatorSchema['tempat_lahir'], new sfValidatorString()
      ), array('required'=>false));

      
      
      $this->validatorSchema['tanggal_lahir'] = new sfValidatorAnd(array(
          $this->validatorSchema['tanggal_lahir'],  new sfValidatorDateTime(array(
              'required'=>false
          ))
      ));

      $this->validatorSchema['alamat'] = new sfValidatorAnd(array(
         $this->validatorSchema['alamat'], new sfValidatorString()
      ), array('required'=>false));

      $this->validatorSchema['email'] = new sfValidatorAnd(array(
            $this->validatorSchema['email'], new sfValidatorEmail(array(),
                    array('invalid'=>'Masukkan alamat email dengan benar',
                        'required'=>'Email harus diisi'))
      ));
  }
}